let Controller = {
	mounted() {
		this.initData();
	},
	activated() {
		this.initData();
		this.getDetail();
	},
	methods: {
		initData() {
			const param = this.$route.query;
			this.Model.queryData = _.cloneDeep(param);
		},
		getFilterData(val) {
			this.Model.searchFromData = val;
		},
		onTableSelectionChange(val) {
			this.Model.exportTableSelectList = val;
		},
		onTabChange(val) {
			switch (val) {
				case 1:
					break;
				case 2:
					break;
				case 3:
					break;
			}
		},
		toggleTableDetail(val) {
		  const obj = this.Model[val];
		  if (obj.flag === true) {
		    this.Model[val].src = require('@/assets/img/icon_collapse.png');
		    this.Model[val].flag = false;
		  } else {
		    this.Model[val].src = require('@/assets/img/icon_unfold.png');
		    this.Model[val].flag = true;
		  }
		},
		// 获取详情
		getDetail() {
			let id = this.$route.query.id
			this.$ajax.get(`${api.supplier}/whWarehouseArrival/detail/list/${id}`).then(res => {
			  if(res.data.status === 200) {
					let data = res.data.result
					this.Model.filterOption.items.map(ele => {
						ele.data = data.warehouse[ele.key] || ''
					})
					this.Model.tableData = data.detailList
			  }
			}).catch(err => {
	  
			})
		},
		// requestDetail() {
		// 	const deliveryNo = this.Model.queryData.data;
		// 	if (deliveryNo) {
		// 		this.$ajax.get(`/api/supplierGoods/dispatchGoods/detail/${deliveryNo}`)
		// 			.then(res => {
		// 				const data = res.data;
		// 				if (data.status == 200) {
		// 					const result = data.result;
		// 					this.setFilterData(result);
		// 				} else {
		// 					this.$message.error(data.msg)
		// 				}

		// 			})
		// 			.catch(error => {
		// 				this.$message.error('请求错误');
		// 			});
		// 	}
		// },
		setFilterData(result) {
			let arr = [result.deliveryNo,result.deliveryStatus,result.isAccreditation,result.accreditationStatus,result.poType,result.deliveryCount,result.deliveryTime];
			arr.forEach((item,index)=>{
				this.filterOption.items[index].data = item;
			});
		},
	}
}
export default Controller;
